﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//import
using ddcCajamarca.BusinessLogic.Documentos.Service;
using Microsoft.Practices.Unity;
using ddcCajamarca.BusinessEntities.Documentos;
using System.Web.ModelBinding;


namespace ddcCajamarca.Web.Documentos
{
    public partial class frmArea : System.Web.UI.Page
    {
        [Dependency]
        public IAreaBL areaBL { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            var accion = Request.QueryString["accion"];
            var id = Request.QueryString["id"];
            if (accion != null && accion == "nuevo")
            {
                fvArea.DefaultMode = FormViewMode.Insert;
            }
            else if (accion != null && id != null && accion == "delete")
            {
                Int32 idArea = Int32.Parse(id);
            }


        }
        public Area GetArea ([QueryString("id")] Int32? id)
        {
            if (id.HasValue)
                return areaBL.getFromAreaById(id.Value);
            return null;
        }
        public void InsertArea (Area area)
        {
            if (ModelState.IsValid)
            {
                areaBL.AddArea(area);
            }
            Response.Redirect("~/Documentos/frmListAreas.aspx");

        }
        public void UpdateArea(Area area)
        {

            if (ModelState.IsValid)
                areaBL.UpdateArea(area);
            Response.Redirect("~/Documentos/frmListAreas.aspx");
        }
    }
}